// 导入axios
import axios from 'axios'
import { base_url } from '../configs/index';
const instance = axios.create({
    baseURL: base_url,
    timeout: 5000,
    // 设置请求头信息
    // headers: {'nickname': 'abc'}
  });


// 添加请求拦截器
instance.interceptors.request.use(function (config) {
    return config;
  }, function (error) {
    return Promise.reject(error);
});

// 添加响应拦截器
instance.interceptors.response.use(function (response) {
    return response;
  }, function (error) {
    return Promise.reject(error);
});

export let get = async (url,params)=>{
    let {data} = await instance.get(url,{params});
    return data;
}
export let post = async (url,params)=>{
    let {data} = await instance.post(url,params);
    return data;
}

export default instance;